#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
    //FILE是结构体，存有文件描述符表的下标，所以对象和指针可以访问结构体内容
    int n = printf("stdin->fd: %d\n", stdin->_fileno);
    printf("stdout->fd: %d\n", stdout->_fileno);
    printf("stderr->fd: %d\n", stderr->_fileno);


    int fp1=open("log1.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
    int fp2=open("log2.txt",O_WRONLY|O_CREAT|O_APPEND,0666);
    int fp3=open("log3.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
    int fp4=open("log4.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
    int fp5=open("log5.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);

    if(fp1<0)
    {
        printf("open fire error\n");
        return 1;
    }

    printf("fp1:%d\n",fp1);
    printf("fp2:%d\n",fp2);
    printf("fp3:%d\n",fp3);
    printf("fp4:%d\n",fp4);
    printf("fp5:%d\n",fp5);
    close(fp1);
    return 0;
}
